def paging_common(data_list, page, size):
    """分页"""
    ret = {
        'page': page, 'size': size, 'total_page': 0, 'total_size': 0
    }
    total_size = len(data_list)
    if total_size % size == 0:
        total_page = total_size / size
    else:
        total_page = total_size / size + 1
    start_index = (page - 1) * size
    end_index = page * size
    
    ret['total_page'] = total_page
    ret['total_size'] = total_size
    if end_index > len(data_list):
        ret['result'] = data_list[start_index:]
    else:
        ret['result'] = data_list[start_index: end_index]
    return ret


def paging_simple(data_list, page, size):
    """分页"""
    start_index = (page - 1) * size
    end_index = page * size
    
    if end_index > len(data_list):
        return data_list[start_index:]
    else:
        return data_list[start_index: end_index]


def paging_index(page, size, data_list=None):
    """
    获得分页开始和结尾
    :param data_list:
    :param page:
    :param size:
    :return:
    """
    start_index = (page - 1) * size
    end_index = page * size
    return start_index
    
    # if end_index > len(data_list):
    #     return data_list[start_index:]
    # else:
    #     return data_list[start_index: end_index]
